﻿Public Class Rapport

    Private solgteKakepakker As List(Of KakePakke)
    Private ingredienser As List(Of Ingrediens)
    Private varesalgene As List(Of Varesalg)

    Public Sub New()
        solgteKakepakker = KakePakke.FinnAlle()
        ingredienser = Ingrediens.FinnAlle()
        varesalgene = Varesalg.FinnAlle()


    End Sub

    Public Sub tegnKakepakkeChart()
        Form1.ChartVaresalgene.Visible = False
        Form1.ChartAntPrDato.Visible = False

        Form1.ChartKakePakker.Visible = True

        For Each kp In solgteKakepakker
            Form1.ChartKakePakker.Series("Innkjøpspris").Points.AddXY(kp.id, kp.innkjopsPris)
            Form1.ChartKakePakker.Series("Utsalgspris").Points.AddXY(kp.id, kp.utsalgsPris)
        Next
    End Sub

    Public Sub tegnVaresalgChart()

        Form1.ChartKakePakker.Visible = False
        Form1.ChartAntPrDato.Visible = False

        Form1.ChartVaresalgene.Visible = True

        For Each vs In varesalgene
            Form1.ChartVaresalgene.Series("Kostpris").Points.AddXY(vs.id, vs.FinnInnkjopspris)
            Form1.ChartVaresalgene.Series("Salgsbeløp").Points.AddXY(vs.id, vs.salgsBeløp)
            Form1.ChartVaresalgene.Series("Avanse").Points.AddXY(vs.id, vs.salgsBeløp - vs.FinnInnkjopspris)
        Next
    End Sub

    Public Sub tegnVaresalgPrDatoChart(ByVal datoOgAnt As Dictionary(Of String, Integer))

        Form1.ChartVaresalgene.Visible = False
        Form1.ChartKakePakker.Visible = False

        Form1.ChartAntPrDato.Series("Antall leveranser").Points.Clear()
        Form1.ChartAntPrDato.Visible = True

        Dim par As KeyValuePair(Of String, Integer)
        For Each par In datoOgAnt
            Form1.ChartAntPrDato.Series("Antall leveranser").Points.AddXY(par.Key, par.Value)
        Next


    End Sub

End Class